package com.CuiChangHe.controller;

import com.CuiChangHe.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;

@Controller
@RequestMapping("/")
public class UserController {
    @Autowired
    private UserService userService;
    @GetMapping("/findAll")
    public String findAll(Model model){
        model.addAttribute("AllUser",userService.findAll());
        return "findAll";
    }
    @RequestMapping("/gotoTestPage")
    public String gotoTestPage(){
        return "test";
    }

    @GetMapping("/findViaId")
    public String findViaId(Model model, @RequestParam(value = "userId",required = true)int id){
        model.addAttribute("AllUser",userService.findViaId(id));
        return "findResult";
    }
}
